var main = new Vue({
	el: '#main',
	data: {
//		info: sessionStorage.yihu_detail == 'undefined' ? {}:JSON.parse(sessionStorage.yihu_detail) ,
		info:JSON.parse(sessionStorage.yihu_detail||'{}') ,
		level:0,//等级
		tcshow:false,
		formstyle:1,//填写状态
		signin:false,//是否签到
		qiandaoTime:"",//签到时间
		qiandaoadress:"",//签到地点
		checkInPhoto:"",//签到图片
		checkOutPhoto:"",//签退图片
		ip:localStorage.ip,
		ios:iosipone,
		checkoutime:"",//签出时间
		ip:localStorage.ip,
	},
	methods:{
		qiandao:function(){
			this.qiandaoTime=new Date().toLocaleString();
			sessionStorage.qiandaoTime=this.qiandaoTime;
			this.qiandaoadress=this.info.address;
			qiandaoajax()
		},
		telipon:function(ipon){
			console.log("调用iOS方法"+ipon)
			secondClick(ipon)
		},
		loadingfu:function(){
			if(!this.ios){
				showLoading()
			}
		}
	},
	mounted:function(){
//	    alert("mounted:组件挂载后，此方法执行后，页面显示")
	 },
})
//上传图片
var filer="";
function verify(val) {
	var file = document.getElementById("file").files[0];
	var imgtype = file.type
	console.log("图片格式:"+imgtype)
	if(imgtype == "image/jpeg" || imgtype == "image/png") {
		var reader = new FileReader();
		reader.onload= function (e) {
            document.getElementById('imgdome').setAttribute('src', e.target.result);
			filer=e.target.result;
        };
        reader.readAsDataURL(file);
     }else {
		log_message("请上传jpg或PNG格式的图片")
	}
}

function qiandaoajax(){
	if(!filer){
		log_message("记得拍照哦")
		return false;
	}
	lrz(filer,{
		width:512
	})
	.then(function(rst){
		ajaxPost(
			Url.ASSESS_CHECKIN,
			{
				"medicalId":main.info.medicalId,
				"file":rst.base64.match(/base64,(\S*)/)[1]
			},
			function(data){
				console.log(data)
				if(data.status == "1"){
					log_message("签到成功")
					main.signin=true;
				}
			}
		)
	})
}
ajaxPost(
	Url.ASSESS_CHECKININFO,
	{
		workOrderId:JSON.parse(sessionStorage.yihu_detail||'{}').medicalId
	},
	function(data){
		console.log(data)
		if(data.status == "1" && data.response[0]){
			if(data.response[0].checkInPhoto){
				main.signin=true;
				main.qiandaoTime=data.response[0].checkInTime;
				main.checkInPhoto=data.response[0].checkInPhoto;
				main.checkOutPhoto=data.response[0].checkOutPhoto;
				main.qiandaoadress=main.info.address;
				main.checkoutime=data.response[0].checkOutTime;
			}
		}
	}
)
document.getElementById("main").setAttribute("style","display: block;");